package com.mvc.handler;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

public class TypeHandlerManager {
	private static final  Map<Class<?>, ParameterTypeHandler<?>> handlers = new HashMap<>();
	
	static {
		handlers.put(int.class, new IntTypeHandler());
		handlers.put(Integer.class, new IntTypeHandler());
		
		handlers.put(long.class, new LongTypeHandler());
		handlers.put(Long.class, new LongTypeHandler());
		
		handlers.put(float.class, new FloatTypeHandler());
		handlers.put(Float.class, new FloatTypeHandler());
		
		handlers.put(double.class, new DoubleTypeHandler());
		handlers.put(Double.class, new DoubleTypeHandler());
		
		handlers.put(LocalDate.class, new LocalDateTypeHandler());
		handlers.put(LocalDateTime.class, new LocalDateTimeTypeHandler());
		
		handlers.put(String.class,new StringTypeHandler());   // 无聊么这是
		
		
		
		
	}
	
	public static ParameterTypeHandler<?> getHandler(Class<?> parameterType){
		
		return handlers.get(parameterType);
	}
}
